<?php

namespace app\bll;

use support\Db;

class ComponentExtendMethod
{
    /**
     * 获取单个信息
     *
     * @param integer $id
     * @return array
     */
    public function find(int $id): array
    {
        $data =  Db::table('frame_component_extend_method')
            ->where('id', '=', $id)
            ->first();
        return $data === null ? [] : get_object_vars($data);
    }

    /**
     * 查询
     *
     * @param integer|null $extendid
     * @return array
     */
    public function select(?int $extendid = null): array
    {
        return Db::table('frame_component_extend_method')
            ->when($extendid, function ($query) use ($extendid) {
                $query->where('extendid', '=', $extendid);
            })
            ->get()
            ->map(function ($value) {
                return (array)$value;
            })
            ->toArray();
    }
}
